<template>
  <div v-loading="isLoading">
    <el-card v-for="item in list" :key="item.id" class="course-item">
      <el-row type="flex" align="middle">
        <div style="width: 130px; border-right: 1px solid; margin-right: 20px;">
          {{ parseTime(item.classTime[0].startTime, '{h}:{i}') +
            '-' + parseTime(item.classTime[0].endTime, '{h}:{i}') }}
        </div>
        <div style="width: 90%; font-size: 20px;">
          {{ item.name }}
        </div>
        <div style="width: 200px;">
          上课地点：{{ item.classTime[0].place }}
        </div>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { getTodayCourse } from '@/api/course'
import { parseTime } from '@/utils'

export default {
  name: 'TodayCourse',
  data() {
    return {
      list: [],
      isLoading: true
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.isLoading = true
      getTodayCourse().then(res => {
        this.list = res.data
        this.isLoading = false
      })
    },
    parseTime
  }
}
</script>

<style scoped>
.course-item {
  margin: 10px;
  background-color: #FFF;
}
</style>
